#include"Socket.hpp"
#include<string>

using namespace SocketModule;

int main(int argc,char *argv[])
{
    if(argc!=3)
    {
        cout<<"client serverip serverport"<<endl;
        return 1;
    }
    SockPtr sock=make_shared<TcpSocket>();
    sock->BuildSocket(SockType::ORDINARY_SOCK);

    uint16_t server_port=stoi(argv[2]);

    sock->Connect(ntohl(inet_addr(argv[1])),server_port);

    while(true)
    {
        cout<<"client# ";
        string out;
        string in;
        getline(cin,out);

        sock->Send(out);

        sock->Recv(in);
        cout<<in<<endl;
    }
    return 0;
}